let Vm = new Vue({
    el: "#app",
    data: {
        books: [
            { id: 1, name: "大鱼", time: new Date().toLocaleString(), price: 44, count: 1 },
            { id: 2, name: "不将就", time: new Date().toLocaleString(), price: 64, count: 1 },
            { id: 3, name: "半句再见", time: new Date().toLocaleString(), price: 55, count: 1 },
            { id: 4, name: "我不难过", time: new Date().toLocaleString(), price: 44, count: 1 },
        ]
    },
    methods: {
        incremoe(index) {
            this.books[index].count++;
        },
        decremoe(index) {
            this.books[index].count--;
        },
        delitem(index) {
            this.books.splice(index, 1);
        }
    },
    filters: {
        test(price) {
            return "￥" + price.toFixed(2);
        }
    },
    computed: {
        totalmoney() {
            var total = 0;
            for (item of this.books) {
                total += item.price * item.count;
            }
            return total;
        }
    }
})